{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "9ac3cde2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from dotenv import load_dotenv\n",
    "\n",
    "load_dotenv()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e0f41184",
   "metadata": {},
   "source": [
    "## Test new YFinance Tool"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "24fbcb71",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008000; text-decoration-color: #008000\">╭───────────────────────── </span><span style=\"color: #008000; text-decoration-color: #008000; font-weight: bold\">🤖 Agent Started</span><span style=\"color: #008000; text-decoration-color: #008000\"> ─────────────────────────╮</span>\n",
       "<span style=\"color: #008000; text-decoration-color: #008000\">│</span>  <span style=\"font-weight: bold\">Agent Status:</span>             <span style=\"color: #008000; text-decoration-color: #008000\">🚀 Started to work</span>                      <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
       "<span style=\"color: #008000; text-decoration-color: #008000\">│</span>  <span style=\"font-weight: bold\">Agent Name:</span>               <span style=\"color: #008080; text-decoration-color: #008080\">Finance Agent</span>                           <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
       "<span style=\"color: #008000; text-decoration-color: #008000\">╰────────────────────────────────────────────────────────────────────╯</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[32m╭─\u001b[0m\u001b[32m────────────────────────\u001b[0m\u001b[32m \u001b[0m\u001b[1;32m🤖 Agent Started\u001b[0m\u001b[32m \u001b[0m\u001b[32m────────────────────────\u001b[0m\u001b[32m─╮\u001b[0m\n",
       "\u001b[32m│\u001b[0m  \u001b[1mAgent Status:\u001b[0m             \u001b[32m🚀 Started to work\u001b[0m                      \u001b[32m│\u001b[0m\n",
       "\u001b[32m│\u001b[0m  \u001b[1mAgent Name:\u001b[0m               \u001b[36mFinance Agent\u001b[0m                           \u001b[32m│\u001b[0m\n",
       "\u001b[32m╰────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭─────────────────── </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">Tool Usage Summary (1 tools)</span><span style=\"color: #008080; text-decoration-color: #008080\"> ───────────────────╮</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold\"> Tool Name           Parameters         Result              </span>       <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_current_stock…</span>  <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\":\"AAPL\"}</span>  <span style=\"color: #008000; text-decoration-color: #008000\">{'func': </span>                  <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                         <span style=\"color: #008000; text-decoration-color: #008000\">'273.9500'}</span>                <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">╰────────────────────────────────────────────────────────────────────╯</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[36m╭─\u001b[0m\u001b[36m──────────────────\u001b[0m\u001b[36m \u001b[0m\u001b[1;36mTool Usage Summary (1 tools)\u001b[0m\u001b[36m \u001b[0m\u001b[36m──────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
       "\u001b[36m│\u001b[0m \u001b[1m \u001b[0m\u001b[1mTool Name\u001b[0m\u001b[1m         \u001b[0m\u001b[1m \u001b[0m\u001b[1m \u001b[0m\u001b[1mParameters\u001b[0m\u001b[1m       \u001b[0m\u001b[1m \u001b[0m\u001b[1m \u001b[0m\u001b[1mResult\u001b[0m\u001b[1m             \u001b[0m\u001b[1m \u001b[0m       \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_current_stock…\u001b[0m  \u001b[33m{\"symbol\":\"AAPL\"}\u001b[0m  \u001b[32m{'func': \u001b[0m                  \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                         \u001b[32m'273.9500'}\u001b[0m                \u001b[36m│\u001b[0m\n",
       "\u001b[36m╰────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">╭─────────────────────────── </span><span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0; font-weight: bold\">Task Result</span><span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\"> ────────────────────────────╮</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>  <span style=\"font-weight: bold\">Result:</span>  <span style=\"color: #008000; text-decoration-color: #008000\">The current stock price for Apple (AAPL) is </span>             <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">$273.95.</span>                                                 <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">╰────────────────────────────────────────────────────────────────────╯</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[37m╭─\u001b[0m\u001b[37m──────────────────────────\u001b[0m\u001b[37m \u001b[0m\u001b[1;37mTask Result\u001b[0m\u001b[37m \u001b[0m\u001b[37m───────────────────────────\u001b[0m\u001b[37m─╮\u001b[0m\n",
       "\u001b[37m│\u001b[0m  \u001b[1mResult:\u001b[0m  \u001b[32mThe current stock price for Apple (AAPL) is \u001b[0m             \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32m$273.95.\u001b[0m                                                 \u001b[37m│\u001b[0m\n",
       "\u001b[37m╰────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #800080; text-decoration-color: #800080\">╭─────────────────────────── </span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Task Metrics</span><span style=\"color: #800080; text-decoration-color: #800080\"> ───────────────────────────╮</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>  <span style=\"font-weight: bold\">Price ID:</span>              <span style=\"color: #800080; text-decoration-color: #800080\">0c83e44a-68dd-4b3c-9d3f-09fe7719a6…</span>        <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>                                                                    <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>  <span style=\"font-weight: bold\">Input Tokens:</span>          <span style=\"color: #800080; text-decoration-color: #800080\">1,911</span>                                      <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>  <span style=\"font-weight: bold\">Output Tokens:</span>         <span style=\"color: #800080; text-decoration-color: #800080\">34</span>                                         <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>  <span style=\"font-weight: bold\">Total Estimated Cost:</span>  <span style=\"color: #800080; text-decoration-color: #800080\">$0.0051</span>                                    <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>  <span style=\"font-weight: bold\">Time Taken:</span>            <span style=\"color: #800080; text-decoration-color: #800080\">5.41 seconds</span>                               <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">╰────────────────────────────────────────────────────────────────────╯</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[35m╭─\u001b[0m\u001b[35m──────────────────────────\u001b[0m\u001b[35m \u001b[0m\u001b[1;35mTask Metrics\u001b[0m\u001b[35m \u001b[0m\u001b[35m──────────────────────────\u001b[0m\u001b[35m─╮\u001b[0m\n",
       "\u001b[35m│\u001b[0m  \u001b[1mPrice ID:\u001b[0m              \u001b[35m0c83e44a-68dd-4b3c-9d3f-09fe7719a6…\u001b[0m        \u001b[35m│\u001b[0m\n",
       "\u001b[35m│\u001b[0m                                                                    \u001b[35m│\u001b[0m\n",
       "\u001b[35m│\u001b[0m  \u001b[1mInput Tokens:\u001b[0m          \u001b[35m1,911\u001b[0m                                      \u001b[35m│\u001b[0m\n",
       "\u001b[35m│\u001b[0m  \u001b[1mOutput Tokens:\u001b[0m         \u001b[35m34\u001b[0m                                         \u001b[35m│\u001b[0m\n",
       "\u001b[35m│\u001b[0m  \u001b[1mTotal Estimated Cost:\u001b[0m  \u001b[35m$0.0051\u001b[0m                                    \u001b[35m│\u001b[0m\n",
       "\u001b[35m│\u001b[0m  \u001b[1mTime Taken:\u001b[0m            \u001b[35m5.41 seconds\u001b[0m                               \u001b[35m│\u001b[0m\n",
       "\u001b[35m╰────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008000; text-decoration-color: #008000; font-weight: bold\">[</span><span style=\"color: #008000; text-decoration-color: #008000\">SUCCESS</span><span style=\"color: #008000; text-decoration-color: #008000; font-weight: bold\">]</span> <span style=\"font-weight: bold\">[</span>Agent<span style=\"font-weight: bold\">]</span> Task completed: The current stock price for Apple <span style=\"font-weight: bold\">(</span>AAPL<span style=\"font-weight: bold\">)</span> is $<span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">273.95</span>.\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[1;32m[\u001b[0m\u001b[32mSUCCESS\u001b[0m\u001b[1;32m]\u001b[0m \u001b[1m[\u001b[0mAgent\u001b[1m]\u001b[0m Task completed: The current stock price for Apple \u001b[1m(\u001b[0mAAPL\u001b[1m)\u001b[0m is $\u001b[1;36m273.95\u001b[0m.\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "'The current stock price for Apple (AAPL) is $273.95.'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from upsonic import Agent, Task\n",
    "from upsonic.tools.common_tools import YFinanceTools\n",
    "\n",
    "# Create finance tools instance\n",
    "finance_tools = YFinanceTools()\n",
    "finance_tools.enable_all_tools()\n",
    "\n",
    "# Create task\n",
    "task = Task(\n",
    "    description=\"Get the current stock price for Apple (AAPL)\",\n",
    "    tools=[finance_tools]\n",
    ")\n",
    "\n",
    "# Create agent\n",
    "agent = Agent(model=\"openai/gpt-4o\", name=\"Finance Agent\")\n",
    "\n",
    "# Execute\n",
    "agent.print_do(task)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f04f7808",
   "metadata": {},
   "source": [
    "## Investment Analysis Report"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "0656fa06",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008000; text-decoration-color: #008000\">╭───────────────────────── </span><span style=\"color: #008000; text-decoration-color: #008000; font-weight: bold\">🤖 Agent Started</span><span style=\"color: #008000; text-decoration-color: #008000\"> ─────────────────────────╮</span>\n",
       "<span style=\"color: #008000; text-decoration-color: #008000\">│</span>  <span style=\"font-weight: bold\">Agent Status:</span>             <span style=\"color: #008000; text-decoration-color: #008000\">🚀 Started to work</span>                      <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
       "<span style=\"color: #008000; text-decoration-color: #008000\">│</span>  <span style=\"font-weight: bold\">Agent Name:</span>               <span style=\"color: #008080; text-decoration-color: #008080\">Stock Analyst</span>                           <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
       "<span style=\"color: #008000; text-decoration-color: #008000\">╰────────────────────────────────────────────────────────────────────╯</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[32m╭─\u001b[0m\u001b[32m────────────────────────\u001b[0m\u001b[32m \u001b[0m\u001b[1;32m🤖 Agent Started\u001b[0m\u001b[32m \u001b[0m\u001b[32m────────────────────────\u001b[0m\u001b[32m─╮\u001b[0m\n",
       "\u001b[32m│\u001b[0m  \u001b[1mAgent Status:\u001b[0m             \u001b[32m🚀 Started to work\u001b[0m                      \u001b[32m│\u001b[0m\n",
       "\u001b[32m│\u001b[0m  \u001b[1mAgent Name:\u001b[0m               \u001b[36mStock Analyst\u001b[0m                           \u001b[32m│\u001b[0m\n",
       "\u001b[32m╰────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008080; text-decoration-color: #008080\">╭────────────────── </span><span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">Tool Usage Summary (21 tools)</span><span style=\"color: #008080; text-decoration-color: #008080\"> ───────────────────╮</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span> <span style=\"font-weight: bold\"> Tool Name           Parameters          Result             </span>       <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_company_info</span>    <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": \"AAPL\"}</span>  <span style=\"color: #008000; text-decoration-color: #008000\">{'func': '{\\n  </span>           <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">\"address1\": \"One </span>         <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">Apple Park Way\"...</span>        <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_company_info</span>    <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": \"MSFT\"}</span>  <span style=\"color: #008000; text-decoration-color: #008000\">{'func': '{\\n  </span>           <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">\"address1\": \"One </span>         <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">Microsoft Way\",...</span>        <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_company_info</span>    <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": </span>         <span style=\"color: #008000; text-decoration-color: #008000\">{'func': '{\\n  </span>           <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                      <span style=\"color: #808000; text-decoration-color: #808000\">\"GOOGL\"}</span>            <span style=\"color: #008000; text-decoration-color: #008000\">\"address1\": \"1600 </span>        <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">Amphitheatre P...</span>         <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_current_stock…</span>  <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": \"AAPL\"}</span>  <span style=\"color: #008000; text-decoration-color: #008000\">{'func': </span>                 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">'273.7100'}</span>               <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_current_stock…</span>  <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": \"MSFT\"}</span>  <span style=\"color: #008000; text-decoration-color: #008000\">{'func': </span>                 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">'510.4400'}</span>               <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_current_stock…</span>  <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": </span>         <span style=\"color: #008000; text-decoration-color: #008000\">{'func': </span>                 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                      <span style=\"color: #808000; text-decoration-color: #808000\">\"GOOGL\"}</span>            <span style=\"color: #008000; text-decoration-color: #008000\">'277.2900'}</span>               <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_stock_fundame…</span>  <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": \"AAPL\"}</span>  <span style=\"color: #008000; text-decoration-color: #008000\">{'func': '{\\n  </span>           <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">\"symbol\": </span>                <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">\"AAPL\",\\n  </span>               <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">\"company_na...</span>            <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_stock_fundame…</span>  <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": \"MSFT\"}</span>  <span style=\"color: #008000; text-decoration-color: #008000\">{'func': '{\\n  </span>           <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">\"symbol\": </span>                <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">\"MSFT\",\\n  </span>               <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">\"company_na...</span>            <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_stock_fundame…</span>  <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": </span>         <span style=\"color: #008000; text-decoration-color: #008000\">{'func': '{\\n  </span>           <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                      <span style=\"color: #808000; text-decoration-color: #808000\">\"GOOGL\"}</span>            <span style=\"color: #008000; text-decoration-color: #008000\">\"symbol\": </span>                <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">\"GOOGL\",\\n  </span>              <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">\"company_n...</span>             <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_historical_st…</span>  <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": \"AAPL\",</span>  <span style=\"color: #008000; text-decoration-color: #008000\">{'func': </span>                 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                      <span style=\"color: #808000; text-decoration-color: #808000\">\"period\": \"1mo\", </span>   <span style=\"color: #008000; text-decoration-color: #008000\">'{\"1760414400000\"…</span>        <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                      <span style=\"color: #808000; text-decoration-color: #808000\">\"interval\":...</span>                                <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_historical_st…</span>  <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": \"MSFT\",</span>  <span style=\"color: #008000; text-decoration-color: #008000\">{'func': </span>                 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                      <span style=\"color: #808000; text-decoration-color: #808000\">\"period\": \"1mo\", </span>   <span style=\"color: #008000; text-decoration-color: #008000\">'{\"1760414400000\"…</span>        <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                      <span style=\"color: #808000; text-decoration-color: #808000\">\"interval\":...</span>                                <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_historical_st…</span>  <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": </span>         <span style=\"color: #008000; text-decoration-color: #008000\">{'func': </span>                 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                      <span style=\"color: #808000; text-decoration-color: #808000\">\"GOOGL\", \"period\":</span>  <span style=\"color: #008000; text-decoration-color: #008000\">'{\"1760414400000\"…</span>        <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                      <span style=\"color: #808000; text-decoration-color: #808000\">\"1mo\", </span>                                       <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                      <span style=\"color: #808000; text-decoration-color: #808000\">\"interval\"...</span>                                 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_key_financial…</span>  <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": \"AAPL\"}</span>  <span style=\"color: #008000; text-decoration-color: #008000\">{'func': '{\\n  </span>           <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">\"address1\": \"One </span>         <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">Apple Park Way\"...</span>        <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_key_financial…</span>  <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": \"MSFT\"}</span>  <span style=\"color: #008000; text-decoration-color: #008000\">{'func': '{\\n  </span>           <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">\"address1\": \"One </span>         <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">Microsoft Way\",...</span>        <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_key_financial…</span>  <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": </span>         <span style=\"color: #008000; text-decoration-color: #008000\">{'func': '{\\n  </span>           <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                      <span style=\"color: #808000; text-decoration-color: #808000\">\"GOOGL\"}</span>            <span style=\"color: #008000; text-decoration-color: #008000\">\"address1\": \"1600 </span>        <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">Amphitheatre P...</span>         <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_analyst_recom…</span>  <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": \"AAPL\"}</span>  <span style=\"color: #008000; text-decoration-color: #008000\">{'func': </span>                 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">'{\"0\":{\"period\":\"…</span>        <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_analyst_recom…</span>  <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": \"MSFT\"}</span>  <span style=\"color: #008000; text-decoration-color: #008000\">{'func': </span>                 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">'{\"0\":{\"period\":\"…</span>        <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_analyst_recom…</span>  <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": </span>         <span style=\"color: #008000; text-decoration-color: #008000\">{'func': </span>                 <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                      <span style=\"color: #808000; text-decoration-color: #808000\">\"GOOGL\"}</span>            <span style=\"color: #008000; text-decoration-color: #008000\">'{\"0\":{\"period\":\"…</span>        <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_company_news</span>    <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": \"AAPL\",</span>  <span style=\"color: #008000; text-decoration-color: #008000\">{'func': '[\\n  {\\n</span>        <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                      <span style=\"color: #808000; text-decoration-color: #808000\">\"num_stories\": 5}</span>   <span style=\"color: #008000; text-decoration-color: #008000\">\"id\": </span>                    <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">\"1f9c457b-3eec-3a…</span>        <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_company_news</span>    <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": \"MSFT\",</span>  <span style=\"color: #008000; text-decoration-color: #008000\">{'func': '[\\n  {\\n</span>        <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                      <span style=\"color: #808000; text-decoration-color: #808000\">\"num_stories\": 5}</span>   <span style=\"color: #008000; text-decoration-color: #008000\">\"id\": </span>                    <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                                          <span style=\"color: #008000; text-decoration-color: #008000\">\"7e255966-2da2-36…</span>        <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>  <span style=\"color: #008080; text-decoration-color: #008080\">get_company_news</span>    <span style=\"color: #808000; text-decoration-color: #808000\">{\"symbol\": </span>         <span style=\"color: #008000; text-decoration-color: #008000\">{'func': '[\\n  {\\n</span>        <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                      <span style=\"color: #808000; text-decoration-color: #808000\">\"GOOGL\", </span>           <span style=\"color: #008000; text-decoration-color: #008000\">\"id\": </span>                    <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">│</span>                      <span style=\"color: #808000; text-decoration-color: #808000\">\"num_stories\": 5}</span>   <span style=\"color: #008000; text-decoration-color: #008000\">\"a4849b20-5fad-3a…</span>        <span style=\"color: #008080; text-decoration-color: #008080\">│</span>\n",
       "<span style=\"color: #008080; text-decoration-color: #008080\">╰────────────────────────────────────────────────────────────────────╯</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[36m╭─\u001b[0m\u001b[36m─────────────────\u001b[0m\u001b[36m \u001b[0m\u001b[1;36mTool Usage Summary (21 tools)\u001b[0m\u001b[36m \u001b[0m\u001b[36m──────────────────\u001b[0m\u001b[36m─╮\u001b[0m\n",
       "\u001b[36m│\u001b[0m \u001b[1m \u001b[0m\u001b[1mTool Name\u001b[0m\u001b[1m         \u001b[0m\u001b[1m \u001b[0m\u001b[1m \u001b[0m\u001b[1mParameters\u001b[0m\u001b[1m        \u001b[0m\u001b[1m \u001b[0m\u001b[1m \u001b[0m\u001b[1mResult\u001b[0m\u001b[1m            \u001b[0m\u001b[1m \u001b[0m       \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_company_info\u001b[0m    \u001b[33m{\"symbol\": \"AAPL\"}\u001b[0m  \u001b[32m{'func': '{\\n  \u001b[0m           \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32m\"address1\": \"One \u001b[0m         \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32mApple Park Way\"...\u001b[0m        \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_company_info\u001b[0m    \u001b[33m{\"symbol\": \"MSFT\"}\u001b[0m  \u001b[32m{'func': '{\\n  \u001b[0m           \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32m\"address1\": \"One \u001b[0m         \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32mMicrosoft Way\",...\u001b[0m        \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_company_info\u001b[0m    \u001b[33m{\"symbol\": \u001b[0m         \u001b[32m{'func': '{\\n  \u001b[0m           \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                      \u001b[33m\"GOOGL\"}\u001b[0m            \u001b[32m\"address1\": \"1600 \u001b[0m        \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32mAmphitheatre P...\u001b[0m         \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_current_stock…\u001b[0m  \u001b[33m{\"symbol\": \"AAPL\"}\u001b[0m  \u001b[32m{'func': \u001b[0m                 \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32m'273.7100'}\u001b[0m               \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_current_stock…\u001b[0m  \u001b[33m{\"symbol\": \"MSFT\"}\u001b[0m  \u001b[32m{'func': \u001b[0m                 \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32m'510.4400'}\u001b[0m               \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_current_stock…\u001b[0m  \u001b[33m{\"symbol\": \u001b[0m         \u001b[32m{'func': \u001b[0m                 \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                      \u001b[33m\"GOOGL\"}\u001b[0m            \u001b[32m'277.2900'}\u001b[0m               \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_stock_fundame…\u001b[0m  \u001b[33m{\"symbol\": \"AAPL\"}\u001b[0m  \u001b[32m{'func': '{\\n  \u001b[0m           \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32m\"symbol\": \u001b[0m                \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32m\"AAPL\",\\n  \u001b[0m               \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32m\"company_na...\u001b[0m            \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_stock_fundame…\u001b[0m  \u001b[33m{\"symbol\": \"MSFT\"}\u001b[0m  \u001b[32m{'func': '{\\n  \u001b[0m           \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32m\"symbol\": \u001b[0m                \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32m\"MSFT\",\\n  \u001b[0m               \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32m\"company_na...\u001b[0m            \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_stock_fundame…\u001b[0m  \u001b[33m{\"symbol\": \u001b[0m         \u001b[32m{'func': '{\\n  \u001b[0m           \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                      \u001b[33m\"GOOGL\"}\u001b[0m            \u001b[32m\"symbol\": \u001b[0m                \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32m\"GOOGL\",\\n  \u001b[0m              \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32m\"company_n...\u001b[0m             \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_historical_st…\u001b[0m  \u001b[33m{\"symbol\": \"AAPL\",\u001b[0m  \u001b[32m{'func': \u001b[0m                 \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                      \u001b[33m\"period\": \"1mo\", \u001b[0m   \u001b[32m'{\"1760414400000\"…\u001b[0m        \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                      \u001b[33m\"interval\":...\u001b[0m                                \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_historical_st…\u001b[0m  \u001b[33m{\"symbol\": \"MSFT\",\u001b[0m  \u001b[32m{'func': \u001b[0m                 \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                      \u001b[33m\"period\": \"1mo\", \u001b[0m   \u001b[32m'{\"1760414400000\"…\u001b[0m        \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                      \u001b[33m\"interval\":...\u001b[0m                                \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_historical_st…\u001b[0m  \u001b[33m{\"symbol\": \u001b[0m         \u001b[32m{'func': \u001b[0m                 \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                      \u001b[33m\"GOOGL\", \"period\":\u001b[0m  \u001b[32m'{\"1760414400000\"…\u001b[0m        \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                      \u001b[33m\"1mo\", \u001b[0m                                       \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                      \u001b[33m\"interval\"...\u001b[0m                                 \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_key_financial…\u001b[0m  \u001b[33m{\"symbol\": \"AAPL\"}\u001b[0m  \u001b[32m{'func': '{\\n  \u001b[0m           \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32m\"address1\": \"One \u001b[0m         \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32mApple Park Way\"...\u001b[0m        \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_key_financial…\u001b[0m  \u001b[33m{\"symbol\": \"MSFT\"}\u001b[0m  \u001b[32m{'func': '{\\n  \u001b[0m           \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32m\"address1\": \"One \u001b[0m         \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32mMicrosoft Way\",...\u001b[0m        \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_key_financial…\u001b[0m  \u001b[33m{\"symbol\": \u001b[0m         \u001b[32m{'func': '{\\n  \u001b[0m           \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                      \u001b[33m\"GOOGL\"}\u001b[0m            \u001b[32m\"address1\": \"1600 \u001b[0m        \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32mAmphitheatre P...\u001b[0m         \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_analyst_recom…\u001b[0m  \u001b[33m{\"symbol\": \"AAPL\"}\u001b[0m  \u001b[32m{'func': \u001b[0m                 \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32m'{\"0\":{\"period\":\"…\u001b[0m        \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_analyst_recom…\u001b[0m  \u001b[33m{\"symbol\": \"MSFT\"}\u001b[0m  \u001b[32m{'func': \u001b[0m                 \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32m'{\"0\":{\"period\":\"…\u001b[0m        \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_analyst_recom…\u001b[0m  \u001b[33m{\"symbol\": \u001b[0m         \u001b[32m{'func': \u001b[0m                 \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                      \u001b[33m\"GOOGL\"}\u001b[0m            \u001b[32m'{\"0\":{\"period\":\"…\u001b[0m        \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_company_news\u001b[0m    \u001b[33m{\"symbol\": \"AAPL\",\u001b[0m  \u001b[32m{'func': '[\\n  {\\n\u001b[0m        \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                      \u001b[33m\"num_stories\": 5}\u001b[0m   \u001b[32m\"id\": \u001b[0m                    \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32m\"1f9c457b-3eec-3a…\u001b[0m        \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_company_news\u001b[0m    \u001b[33m{\"symbol\": \"MSFT\",\u001b[0m  \u001b[32m{'func': '[\\n  {\\n\u001b[0m        \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                      \u001b[33m\"num_stories\": 5}\u001b[0m   \u001b[32m\"id\": \u001b[0m                    \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                                          \u001b[32m\"7e255966-2da2-36…\u001b[0m        \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m  \u001b[36mget_company_news\u001b[0m    \u001b[33m{\"symbol\": \u001b[0m         \u001b[32m{'func': '[\\n  {\\n\u001b[0m        \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                      \u001b[33m\"GOOGL\", \u001b[0m           \u001b[32m\"id\": \u001b[0m                    \u001b[36m│\u001b[0m\n",
       "\u001b[36m│\u001b[0m                      \u001b[33m\"num_stories\": 5}\u001b[0m   \u001b[32m\"a4849b20-5fad-3a…\u001b[0m        \u001b[36m│\u001b[0m\n",
       "\u001b[36m╰────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">╭─────────────────────────── </span><span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0; font-weight: bold\">Task Result</span><span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\"> ────────────────────────────╮</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>  <span style=\"font-weight: bold\">Result:</span>  <span style=\"color: #008000; text-decoration-color: #008000\">```markdown</span>                                              <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\"># Market Analysis Report: AAPL, MSFT, GOOGL</span>              <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>                                                                    <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">## Apple Inc. (AAPL)</span>                                     <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>                                                                    <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">### Market Research</span>                                      <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">- **Industry**: Consumer Electronics  </span>                   <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">- **Sector**: Technology  </span>                               <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">- **CEO**: Mr. Timothy D. Cook  </span>                         <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">- **Headquarters**: Cupertino, California  </span>              <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">- **Products**: iPhone, Mac, iPad, AirPods, Apple</span>        <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">TV, Apple Watch  </span>                                        <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">- **Recent Performance**: Current stock price at </span>        <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">$273.71 wit...</span>                                           <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">╰────────────────────────────────────────────────────────────────────╯</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[37m╭─\u001b[0m\u001b[37m──────────────────────────\u001b[0m\u001b[37m \u001b[0m\u001b[1;37mTask Result\u001b[0m\u001b[37m \u001b[0m\u001b[37m───────────────────────────\u001b[0m\u001b[37m─╮\u001b[0m\n",
       "\u001b[37m│\u001b[0m  \u001b[1mResult:\u001b[0m  \u001b[32m```markdown\u001b[0m                                              \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32m# Market Analysis Report: AAPL, MSFT, GOOGL\u001b[0m              \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m                                                                    \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32m## Apple Inc. (AAPL)\u001b[0m                                     \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m                                                                    \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32m### Market Research\u001b[0m                                      \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32m- **Industry**: Consumer Electronics  \u001b[0m                   \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32m- **Sector**: Technology  \u001b[0m                               \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32m- **CEO**: Mr. Timothy D. Cook  \u001b[0m                         \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32m- **Headquarters**: Cupertino, California  \u001b[0m              \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32m- **Products**: iPhone, Mac, iPad, AirPods, Apple\u001b[0m        \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32mTV, Apple Watch  \u001b[0m                                        \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32m- **Recent Performance**: Current stock price at \u001b[0m        \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32m$273.71 wit...\u001b[0m                                           \u001b[37m│\u001b[0m\n",
       "\u001b[37m╰────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #800080; text-decoration-color: #800080\">╭─────────────────────────── </span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Task Metrics</span><span style=\"color: #800080; text-decoration-color: #800080\"> ───────────────────────────╮</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>  <span style=\"font-weight: bold\">Price ID:</span>              <span style=\"color: #800080; text-decoration-color: #800080\">fe366f8e-586c-4ad0-ae17-a8cd58a220…</span>        <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>                                                                    <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>  <span style=\"font-weight: bold\">Input Tokens:</span>          <span style=\"color: #800080; text-decoration-color: #800080\">40,841</span>                                     <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>  <span style=\"font-weight: bold\">Output Tokens:</span>         <span style=\"color: #800080; text-decoration-color: #800080\">1,395</span>                                      <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>  <span style=\"font-weight: bold\">Total Estimated Cost:</span>  <span style=\"color: #800080; text-decoration-color: #800080\">$0.1161</span>                                    <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>  <span style=\"font-weight: bold\">Time Taken:</span>            <span style=\"color: #800080; text-decoration-color: #800080\">66.59 seconds</span>                              <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">╰────────────────────────────────────────────────────────────────────╯</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[35m╭─\u001b[0m\u001b[35m──────────────────────────\u001b[0m\u001b[35m \u001b[0m\u001b[1;35mTask Metrics\u001b[0m\u001b[35m \u001b[0m\u001b[35m──────────────────────────\u001b[0m\u001b[35m─╮\u001b[0m\n",
       "\u001b[35m│\u001b[0m  \u001b[1mPrice ID:\u001b[0m              \u001b[35mfe366f8e-586c-4ad0-ae17-a8cd58a220…\u001b[0m        \u001b[35m│\u001b[0m\n",
       "\u001b[35m│\u001b[0m                                                                    \u001b[35m│\u001b[0m\n",
       "\u001b[35m│\u001b[0m  \u001b[1mInput Tokens:\u001b[0m          \u001b[35m40,841\u001b[0m                                     \u001b[35m│\u001b[0m\n",
       "\u001b[35m│\u001b[0m  \u001b[1mOutput Tokens:\u001b[0m         \u001b[35m1,395\u001b[0m                                      \u001b[35m│\u001b[0m\n",
       "\u001b[35m│\u001b[0m  \u001b[1mTotal Estimated Cost:\u001b[0m  \u001b[35m$0.1161\u001b[0m                                    \u001b[35m│\u001b[0m\n",
       "\u001b[35m│\u001b[0m  \u001b[1mTime Taken:\u001b[0m            \u001b[35m66.59 seconds\u001b[0m                              \u001b[35m│\u001b[0m\n",
       "\u001b[35m╰────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "## Stock Analyst Report\n",
      "\n",
      "```markdown\n",
      "# Market Analysis Report: AAPL, MSFT, GOOGL\n",
      "\n",
      "## Apple Inc. (AAPL)\n",
      "\n",
      "### Market Research\n",
      "- **Industry**: Consumer Electronics  \n",
      "- **Sector**: Technology  \n",
      "- **CEO**: Mr. Timothy D. Cook  \n",
      "- **Headquarters**: Cupertino, California  \n",
      "- **Products**: iPhone, Mac, iPad, AirPods, Apple TV, Apple Watch  \n",
      "- **Recent Performance**: Current stock price at $273.71 with a 52-week high of $277.32  \n",
      "- **Competitive Positioning**: Market leader in consumer electronics with strong brand loyalty  \n",
      "\n",
      "### Financial Analysis\n",
      "- **Market Cap**: $4.04 Trillion  \n",
      "- **PE Ratio**: 32.94  \n",
      "- **Dividend Yield**: 0.38%  \n",
      "- **EPS**: 7.45  \n",
      "- **Beta**: 1.109  \n",
      "- **Analyst Recommendations**: Predominantly \"Buy\" with a mean price target of $281.07  \n",
      "- **Recent News**:\n",
      "  - Apple to benefit from new global tariff agreements (Source: Yahoo Finance)\n",
      "  - Potential Apple Watch import ban by a US trade tribunal (Source: Reuters)\n",
      "\n",
      "### Risk Assessment\n",
      "- **Market Risks**: High competition, especially in consumer electronics and services.  \n",
      "- **Company-Specific Challenges**: Patent disputes and regulatory scrutiny in different markets.  \n",
      "- **Macroeconomic Factors**: Global trade policies and shifting consumer preferences.  \n",
      "- **Potential Red Flags**: High valuation and possible impacts of import restrictions.\n",
      "\n",
      "---\n",
      "\n",
      "## Microsoft Corporation (MSFT)\n",
      "\n",
      "### Market Research\n",
      "- **Industry**: Software - Infrastructure  \n",
      "- **Sector**: Technology  \n",
      "- **CEO**: Mr. Satya Nadella  \n",
      "- **Headquarters**: Redmond, Washington  \n",
      "- **Products**: Microsoft 365, Azure, LinkedIn, Xbox  \n",
      "- **Recent Performance**: Current stock price at $510.44 with a 52-week high of $555.45  \n",
      "- **Competitive Positioning**: Strong position in cloud services and enterprise solutions  \n",
      "\n",
      "### Financial Analysis\n",
      "- **Market Cap**: $3.79 Trillion  \n",
      "- **PE Ratio**: 34.14  \n",
      "- **Dividend Yield**: 0.72%  \n",
      "- **EPS**: 14.04  \n",
      "- **Beta**: 1.065  \n",
      "- **Analyst Recommendations**: Predominantly \"Strong Buy\" with a mean price target exceeding $625  \n",
      "- **Recent News**:\n",
      "  - Microsoft's investment shifts hint at a reduction (Source: GuruFocus)\n",
      "  - AI investing through corporate bonds (Source: Yahoo Finance Video)\n",
      "\n",
      "### Risk Assessment\n",
      "- **Market Risks**: Intense competition in cloud services and software innovation.  \n",
      "- **Company-Specific Challenges**: Market saturation in certain segments.  \n",
      "- **Macroeconomic Factors**: Economic downturns impacting IT budgets.  \n",
      "- **Potential Red Flags**: Oversaturation in traditional markets and emerging disruptive technologies.\n",
      "\n",
      "---\n",
      "\n",
      "## Alphabet Inc. (GOOGL)\n",
      "\n",
      "### Market Research\n",
      "- **Industry**: Internet Content & Information  \n",
      "- **Sector**: Communication Services  \n",
      "- **CEO**: Mr. Sundar Pichai  \n",
      "- **Headquarters**: Mountain View, California  \n",
      "- **Products**: Google Search, YouTube, Android, Google Cloud  \n",
      "- **Recent Performance**: Current stock price at $277.29 with a 52-week high of $292.01  \n",
      "- **Competitive Positioning**: Dominant player in digital advertising and cloud services  \n",
      "\n",
      "### Financial Analysis\n",
      "- **Market Cap**: $3.35 Trillion  \n",
      "- **PE Ratio**: 30.95  \n",
      "- **Dividend Yield**: 0.3%  \n",
      "- **EPS**: 10.14  \n",
      "- **Beta**: 1.082  \n",
      "- **Analyst Recommendations**: Predominantly \"Strong Buy\" with high growth expectations  \n",
      "- **Recent News**:\n",
      "  - Concerns over an AI bubble due to AI investments via corporate debt (Source: Yahoo Finance Video)\n",
      "  - Sector updates highlight tech stock rise (Source: MT Newswires)\n",
      "\n",
      "### Risk Assessment\n",
      "- **Market Risks**: Privacy regulations and antitrust scrutiny globally.  \n",
      "- **Company-Specific Challenges**: Managing data security and privacy concerns.  \n",
      "- **Macroeconomic Factors**: Ad-spending fluctuations and regulatory changes.  \n",
      "- **Potential Red Flags**: Regulatory challenges and market volatility related to AI investments.\n",
      "\n",
      "---\n",
      "\n",
      "### Disclaimer\n",
      "This report is for educational purposes only and does not constitute financial advice.\n",
      "```\n"
     ]
    }
   ],
   "source": [
    "from upsonic import Agent, Task\n",
    "from upsonic.tools.common_tools import YFinanceTools\n",
    "from textwrap import dedent\n",
    "\n",
    "yfinance_tools = YFinanceTools(\n",
    "    company_info=True,\n",
    "    analyst_recommendations=True,\n",
    "    company_news=True,\n",
    "    stock_price=True,\n",
    "    enable_all=True\n",
    ")\n",
    "\n",
    "yfinance_tools.enable_all_tools()\n",
    "\n",
    "stock_analyst = Agent(name=\"Stock Analyst\")\n",
    "research_analyst = Agent(name=\"Research Analyst\")\n",
    "investment_lead = Agent(name=\"Investment Lead\")\n",
    "\n",
    "\n",
    "companies = \"AAPL, MSFT, GOOGL\" \n",
    "\n",
    "task1 = Task(\n",
    "    description=dedent(f\"\"\"\\\n",
    "        You are MarketMaster-X, an elite Senior Investment Analyst at Goldman Sachs with expertise in:\n",
    "        - Comprehensive market analysis\n",
    "        - Financial statement evaluation\n",
    "        - Industry trend identification\n",
    "        - News impact assessment\n",
    "        - Risk factor analysis\n",
    "        - Growth potential evaluation\n",
    "\n",
    "        Instructions:\n",
    "        1. Market Research 📊\n",
    "           - Analyze company fundamentals and metrics\n",
    "           - Review recent market performance\n",
    "           - Evaluate competitive positioning\n",
    "           - Assess industry trends and dynamics\n",
    "        2. Financial Analysis 💹\n",
    "           - Examine key financial ratios\n",
    "           - Review analyst recommendations\n",
    "           - Analyze recent news impact\n",
    "           - Identify growth catalysts\n",
    "        3. Risk Assessment 🎯\n",
    "           - Evaluate market risks\n",
    "           - Assess company-specific challenges\n",
    "           - Consider macroeconomic factors\n",
    "           - Identify potential red flags\n",
    "        Note: This analysis is for educational purposes only.\n",
    "\n",
    "        Analyze the following companies and produce a comprehensive market analysis report in markdown format: {companies}\n",
    "    \"\"\"),\n",
    "    tools=[finance_tools]\n",
    ")\n",
    "report1 = stock_analyst.do(task1)\n",
    "print(\"## Stock Analyst Report\\n\")\n",
    "print(report1)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "741a05ff",
   "metadata": {},
   "source": [
    "# Research Analyst"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "25741c40",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008000; text-decoration-color: #008000\">╭───────────────────────── </span><span style=\"color: #008000; text-decoration-color: #008000; font-weight: bold\">🤖 Agent Started</span><span style=\"color: #008000; text-decoration-color: #008000\"> ─────────────────────────╮</span>\n",
       "<span style=\"color: #008000; text-decoration-color: #008000\">│</span>  <span style=\"font-weight: bold\">Agent Status:</span>             <span style=\"color: #008000; text-decoration-color: #008000\">🚀 Started to work</span>                      <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
       "<span style=\"color: #008000; text-decoration-color: #008000\">│</span>  <span style=\"font-weight: bold\">Agent Name:</span>               <span style=\"color: #008080; text-decoration-color: #008080\">Research Analyst</span>                        <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
       "<span style=\"color: #008000; text-decoration-color: #008000\">╰────────────────────────────────────────────────────────────────────╯</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[32m╭─\u001b[0m\u001b[32m────────────────────────\u001b[0m\u001b[32m \u001b[0m\u001b[1;32m🤖 Agent Started\u001b[0m\u001b[32m \u001b[0m\u001b[32m────────────────────────\u001b[0m\u001b[32m─╮\u001b[0m\n",
       "\u001b[32m│\u001b[0m  \u001b[1mAgent Status:\u001b[0m             \u001b[32m🚀 Started to work\u001b[0m                      \u001b[32m│\u001b[0m\n",
       "\u001b[32m│\u001b[0m  \u001b[1mAgent Name:\u001b[0m               \u001b[36mResearch Analyst\u001b[0m                        \u001b[32m│\u001b[0m\n",
       "\u001b[32m╰────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">╭─────────────────────────── </span><span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0; font-weight: bold\">Task Result</span><span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\"> ────────────────────────────╮</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>  <span style=\"font-weight: bold\">Result:</span>  <span style=\"color: #008000; text-decoration-color: #008000\">```markdown</span>                                              <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\"># Investment Analysis and Ranking Report: AAPL, </span>         <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">MSFT, GOOGL</span>                                              <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>                                                                    <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">## Overview</span>                                              <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">This report evaluates the investment potential of</span>        <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">Apple Inc. (AAPL), Microsoft Corporation (MSFT), </span>        <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">and Alphabet Inc. (GOOGL) based on current market</span>        <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">analysis. Each company's potential is assessed </span>          <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">through investment analysis, risk evaluation, and</span>        <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">competitive positioning to provide a ra...</span>               <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">╰────────────────────────────────────────────────────────────────────╯</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[37m╭─\u001b[0m\u001b[37m──────────────────────────\u001b[0m\u001b[37m \u001b[0m\u001b[1;37mTask Result\u001b[0m\u001b[37m \u001b[0m\u001b[37m───────────────────────────\u001b[0m\u001b[37m─╮\u001b[0m\n",
       "\u001b[37m│\u001b[0m  \u001b[1mResult:\u001b[0m  \u001b[32m```markdown\u001b[0m                                              \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32m# Investment Analysis and Ranking Report: AAPL, \u001b[0m         \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32mMSFT, GOOGL\u001b[0m                                              \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m                                                                    \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32m## Overview\u001b[0m                                              \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32mThis report evaluates the investment potential of\u001b[0m        \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32mApple Inc. (AAPL), Microsoft Corporation (MSFT), \u001b[0m        \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32mand Alphabet Inc. (GOOGL) based on current market\u001b[0m        \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32manalysis. Each company's potential is assessed \u001b[0m          \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32mthrough investment analysis, risk evaluation, and\u001b[0m        \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32mcompetitive positioning to provide a ra...\u001b[0m               \u001b[37m│\u001b[0m\n",
       "\u001b[37m╰────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #800080; text-decoration-color: #800080\">╭─────────────────────────── </span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Task Metrics</span><span style=\"color: #800080; text-decoration-color: #800080\"> ───────────────────────────╮</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>  <span style=\"font-weight: bold\">Price ID:</span>              <span style=\"color: #800080; text-decoration-color: #800080\">5230eb89-cae4-49b2-844a-ffda3b5e12…</span>        <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>                                                                    <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>  <span style=\"font-weight: bold\">Input Tokens:</span>          <span style=\"color: #800080; text-decoration-color: #800080\">1,374</span>                                      <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>  <span style=\"font-weight: bold\">Output Tokens:</span>         <span style=\"color: #800080; text-decoration-color: #800080\">804</span>                                        <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>  <span style=\"font-weight: bold\">Total Estimated Cost:</span>  <span style=\"color: #800080; text-decoration-color: #800080\">$0.0115</span>                                    <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>  <span style=\"font-weight: bold\">Time Taken:</span>            <span style=\"color: #800080; text-decoration-color: #800080\">17.96 seconds</span>                              <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">╰────────────────────────────────────────────────────────────────────╯</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[35m╭─\u001b[0m\u001b[35m──────────────────────────\u001b[0m\u001b[35m \u001b[0m\u001b[1;35mTask Metrics\u001b[0m\u001b[35m \u001b[0m\u001b[35m──────────────────────────\u001b[0m\u001b[35m─╮\u001b[0m\n",
       "\u001b[35m│\u001b[0m  \u001b[1mPrice ID:\u001b[0m              \u001b[35m5230eb89-cae4-49b2-844a-ffda3b5e12…\u001b[0m        \u001b[35m│\u001b[0m\n",
       "\u001b[35m│\u001b[0m                                                                    \u001b[35m│\u001b[0m\n",
       "\u001b[35m│\u001b[0m  \u001b[1mInput Tokens:\u001b[0m          \u001b[35m1,374\u001b[0m                                      \u001b[35m│\u001b[0m\n",
       "\u001b[35m│\u001b[0m  \u001b[1mOutput Tokens:\u001b[0m         \u001b[35m804\u001b[0m                                        \u001b[35m│\u001b[0m\n",
       "\u001b[35m│\u001b[0m  \u001b[1mTotal Estimated Cost:\u001b[0m  \u001b[35m$0.0115\u001b[0m                                    \u001b[35m│\u001b[0m\n",
       "\u001b[35m│\u001b[0m  \u001b[1mTime Taken:\u001b[0m            \u001b[35m17.96 seconds\u001b[0m                              \u001b[35m│\u001b[0m\n",
       "\u001b[35m╰────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "## Research Analyst Report\n",
      "\n",
      "```markdown\n",
      "# Investment Analysis and Ranking Report: AAPL, MSFT, GOOGL\n",
      "\n",
      "## Overview\n",
      "This report evaluates the investment potential of Apple Inc. (AAPL), Microsoft Corporation (MSFT), and Alphabet Inc. (GOOGL) based on current market analysis. Each company's potential is assessed through investment analysis, risk evaluation, and competitive positioning to provide a ranking based on investment potential.\n",
      "\n",
      "## Detailed Analyses\n",
      "\n",
      "### 1. Apple Inc. (AAPL)\n",
      "\n",
      "#### Investment Analysis 🔍\n",
      "- **Market Leadership**: Strong brand loyalty and leadership in consumer electronics.\n",
      "- **Financial Strength**: High market cap of $4.04 trillion and solid valuation metrics with a PE ratio of 32.94.\n",
      "- **Strategic Positioning**: Expanding product ecosystem and benefiting from global tariff agreements.\n",
      "\n",
      "#### Risk Evaluation 📈\n",
      "- **Risk Factors**: High competition, patent disputes, and possible import restrictions.\n",
      "- **Market Conditions**: Shifting consumer preferences and regulatory scrutiny.\n",
      "- **Growth Sustainability**: Leveraging brand loyalty, but risk from high valuation.\n",
      "\n",
      "#### Competitive Advantages\n",
      "- Strong brand and diverse product portfolio.\n",
      "- Loyal customer base and robust financial performance.\n",
      "\n",
      "### 2. Microsoft Corporation (MSFT)\n",
      "\n",
      "#### Investment Analysis 🔍\n",
      "- **Market Cap and Valuation**: $3.79 trillion market cap with a PE ratio of 34.14.\n",
      "- **Growth Drivers**: Dominant in cloud services and enterprise solutions.\n",
      "- **Performance**: Robust earnings potential with an EPS of 14.04.\n",
      "\n",
      "#### Risk Evaluation 📈\n",
      "- **Risk Factors**: Market saturation and emerging disruptive technologies.\n",
      "- **Market Conditions**: Economic downturn impact on IT budget allocation.\n",
      "- **Growth Sustainability**: Strong cloud segment offsets risks in traditional markets.\n",
      "\n",
      "#### Competitive Advantages\n",
      "- Leadership in enterprise software and cloud platform.\n",
      "- Diversified product and service offerings across sectors.\n",
      "\n",
      "### 3. Alphabet Inc. (GOOGL)\n",
      "\n",
      "#### Investment Analysis 🔍\n",
      "- **Valuation and Scale**: Market cap of $3.35 trillion and a PE ratio of 30.95.\n",
      "- **Growth Potential**: Highest EPS growth potential (10.14) with focused digital advertising strategy.\n",
      "- **Innovation**: Pioneering efforts in AI and data services.\n",
      "\n",
      "#### Risk Evaluation 📈\n",
      "- **Risk Factors**: Privacy regulations and antitrust challenges worldwide.\n",
      "- **Market Conditions**: Volatility due to AI market and regulatory landscape.\n",
      "- **Growth Sustainability**: High growth potential but susceptible to sector-related policy changes.\n",
      "\n",
      "#### Competitive Advantages\n",
      "- Dominance in digital advertising and cloud services.\n",
      "- Strong innovation culture and technological proficiency.\n",
      "\n",
      "## Company Ranking 🏆\n",
      "\n",
      "1. **Microsoft Corporation (MSFT)**\n",
      "   - **Rationale**: Microsoft's strong positioning in cloud computing and enterprise solutions, combined with robust financial performance and strategic diversification, offers exceptional growth potential amidst manageable risks. High analyst confidence supports its top rank.\n",
      "\n",
      "2. **Apple Inc. (AAPL)**\n",
      "   - **Rationale**: Although Apple showcases strong market leadership and brand loyalty, potential regulatory challenges and high competition in the consumer electronics sector introduce moderate risk. However, its strong financials justify a solid investment stance.\n",
      "\n",
      "3. **Alphabet Inc. (GOOGL)**\n",
      "   - **Rationale**: While Alphabet leads in digital advertising and offers high growth potential, regulatory challenges and sector volatility pose significant risks. Overcoming these hurdles could substantially enhance long-term value.\n",
      "\n",
      "---\n",
      "\n",
      "### Conclusion\n",
      "Each analyzed company presents unique strengths and challenges. Microsoft emerges as the most balanced investment opportunity given its robust market position and diversified growth avenues. Apple's consumer electronic dominance provides a stronghold with caution due to regulatory risks, whereas Alphabet's innovation potential is promising if regulatory challenges are effectively managed.\n",
      "\n",
      "### Disclaimer\n",
      "This report is for informational purposes only and should not be construed as investment advice. Investment decisions should be made based on individual financial circumstances and consultation with a financial advisor.\n",
      "```\n"
     ]
    }
   ],
   "source": [
    "\n",
    "\n",
    "task2 = Task(\n",
    "    description=dedent(f\"\"\"\\\n",
    "        You are ValuePro-X, an elite Senior Research Analyst at Goldman Sachs specializing in:\n",
    "        - Investment opportunity evaluation\n",
    "        - Comparative analysis\n",
    "        - Risk-reward assessment\n",
    "        - Growth potential ranking\n",
    "        - Strategic recommendations\n",
    "\n",
    "        Instructions:\n",
    "        1. Investment Analysis 🔍\n",
    "           - Evaluate each company's potential\n",
    "           - Compare relative valuations\n",
    "           - Assess competitive advantages\n",
    "           - Consider market positioning\n",
    "        2. Risk Evaluation 📈\n",
    "           - Analyze risk factors\n",
    "           - Consider market conditions\n",
    "           - Evaluate growth sustainability\n",
    "           - Assess management capability\n",
    "        3. Company Ranking 🏆\n",
    "           - Rank based on investment potential\n",
    "           - Provide detailed rationale\n",
    "           - Consider risk-adjusted returns\n",
    "           - Explain competitive advantages\n",
    "\n",
    "        Based on the following market analysis, rank the companies by investment potential and provide a detailed investment analysis and ranking report in markdown format:\n",
    "\n",
    "        {report1}\n",
    "    \"\"\"),\n",
    "    tools=[]\n",
    ")\n",
    "report2 = research_analyst.do(task2)\n",
    "print(\"\\n## Research Analyst Report\\n\")\n",
    "print(report2)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2fc986be",
   "metadata": {},
   "source": [
    "# Investment Lead"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ca2cbd56",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #008000; text-decoration-color: #008000\">╭───────────────────────── </span><span style=\"color: #008000; text-decoration-color: #008000; font-weight: bold\">🤖 Agent Started</span><span style=\"color: #008000; text-decoration-color: #008000\"> ─────────────────────────╮</span>\n",
       "<span style=\"color: #008000; text-decoration-color: #008000\">│</span>  <span style=\"font-weight: bold\">Agent Status:</span>             <span style=\"color: #008000; text-decoration-color: #008000\">🚀 Started to work</span>                      <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
       "<span style=\"color: #008000; text-decoration-color: #008000\">│</span>  <span style=\"font-weight: bold\">Agent Name:</span>               <span style=\"color: #008080; text-decoration-color: #008080\">Investment Lead</span>                         <span style=\"color: #008000; text-decoration-color: #008000\">│</span>\n",
       "<span style=\"color: #008000; text-decoration-color: #008000\">╰────────────────────────────────────────────────────────────────────╯</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[32m╭─\u001b[0m\u001b[32m────────────────────────\u001b[0m\u001b[32m \u001b[0m\u001b[1;32m🤖 Agent Started\u001b[0m\u001b[32m \u001b[0m\u001b[32m────────────────────────\u001b[0m\u001b[32m─╮\u001b[0m\n",
       "\u001b[32m│\u001b[0m  \u001b[1mAgent Status:\u001b[0m             \u001b[32m🚀 Started to work\u001b[0m                      \u001b[32m│\u001b[0m\n",
       "\u001b[32m│\u001b[0m  \u001b[1mAgent Name:\u001b[0m               \u001b[36mInvestment Lead\u001b[0m                         \u001b[32m│\u001b[0m\n",
       "\u001b[32m╰────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">╭─────────────────────────── </span><span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0; font-weight: bold\">Task Result</span><span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\"> ────────────────────────────╮</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>  <span style=\"font-weight: bold\">Result:</span>  <span style=\"color: #008000; text-decoration-color: #008000\">```markdown</span>                                              <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\"># Final Investment Report: AAPL, MSFT, GOOGL</span>             <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>                                                                    <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">## 1. Portfolio Strategy Development 💼</span>                  <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>                                                                    <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">### Allocation Strategy</span>                                  <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">- **Microsoft Corporation (MSFT)**: Allocate 40%</span>         <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">  - Justification: Strong market leadership in </span>          <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">cloud and enterprise solutions represents </span>               <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">sustainable growth. Manages risks effectively due</span>        <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">to diversification and robust financial health.</span>          <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">  </span>                                                       <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>           <span style=\"color: #008000; text-decoration-color: #008000\">- **Apple...</span>                                             <span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">│</span>\n",
       "<span style=\"color: #c0c0c0; text-decoration-color: #c0c0c0\">╰────────────────────────────────────────────────────────────────────╯</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[37m╭─\u001b[0m\u001b[37m──────────────────────────\u001b[0m\u001b[37m \u001b[0m\u001b[1;37mTask Result\u001b[0m\u001b[37m \u001b[0m\u001b[37m───────────────────────────\u001b[0m\u001b[37m─╮\u001b[0m\n",
       "\u001b[37m│\u001b[0m  \u001b[1mResult:\u001b[0m  \u001b[32m```markdown\u001b[0m                                              \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32m# Final Investment Report: AAPL, MSFT, GOOGL\u001b[0m             \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m                                                                    \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32m## 1. Portfolio Strategy Development 💼\u001b[0m                  \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m                                                                    \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32m### Allocation Strategy\u001b[0m                                  \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32m- **Microsoft Corporation (MSFT)**: Allocate 40%\u001b[0m         \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32m  - Justification: Strong market leadership in \u001b[0m          \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32mcloud and enterprise solutions represents \u001b[0m               \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32msustainable growth. Manages risks effectively due\u001b[0m        \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32mto diversification and robust financial health.\u001b[0m          \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32m  \u001b[0m                                                       \u001b[37m│\u001b[0m\n",
       "\u001b[37m│\u001b[0m           \u001b[32m- **Apple...\u001b[0m                                             \u001b[37m│\u001b[0m\n",
       "\u001b[37m╰────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #800080; text-decoration-color: #800080\">╭─────────────────────────── </span><span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">Task Metrics</span><span style=\"color: #800080; text-decoration-color: #800080\"> ───────────────────────────╮</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>  <span style=\"font-weight: bold\">Price ID:</span>              <span style=\"color: #800080; text-decoration-color: #800080\">41298312-4f0f-4d13-ac28-bdfe6d9a81…</span>        <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>                                                                    <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>  <span style=\"font-weight: bold\">Input Tokens:</span>          <span style=\"color: #800080; text-decoration-color: #800080\">1,225</span>                                      <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>  <span style=\"font-weight: bold\">Output Tokens:</span>         <span style=\"color: #800080; text-decoration-color: #800080\">610</span>                                        <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>  <span style=\"font-weight: bold\">Total Estimated Cost:</span>  <span style=\"color: #800080; text-decoration-color: #800080\">$0.0092</span>                                    <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">│</span>  <span style=\"font-weight: bold\">Time Taken:</span>            <span style=\"color: #800080; text-decoration-color: #800080\">15.26 seconds</span>                              <span style=\"color: #800080; text-decoration-color: #800080\">│</span>\n",
       "<span style=\"color: #800080; text-decoration-color: #800080\">╰────────────────────────────────────────────────────────────────────╯</span>\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\u001b[35m╭─\u001b[0m\u001b[35m──────────────────────────\u001b[0m\u001b[35m \u001b[0m\u001b[1;35mTask Metrics\u001b[0m\u001b[35m \u001b[0m\u001b[35m──────────────────────────\u001b[0m\u001b[35m─╮\u001b[0m\n",
       "\u001b[35m│\u001b[0m  \u001b[1mPrice ID:\u001b[0m              \u001b[35m41298312-4f0f-4d13-ac28-bdfe6d9a81…\u001b[0m        \u001b[35m│\u001b[0m\n",
       "\u001b[35m│\u001b[0m                                                                    \u001b[35m│\u001b[0m\n",
       "\u001b[35m│\u001b[0m  \u001b[1mInput Tokens:\u001b[0m          \u001b[35m1,225\u001b[0m                                      \u001b[35m│\u001b[0m\n",
       "\u001b[35m│\u001b[0m  \u001b[1mOutput Tokens:\u001b[0m         \u001b[35m610\u001b[0m                                        \u001b[35m│\u001b[0m\n",
       "\u001b[35m│\u001b[0m  \u001b[1mTotal Estimated Cost:\u001b[0m  \u001b[35m$0.0092\u001b[0m                                    \u001b[35m│\u001b[0m\n",
       "\u001b[35m│\u001b[0m  \u001b[1mTime Taken:\u001b[0m            \u001b[35m15.26 seconds\u001b[0m                              \u001b[35m│\u001b[0m\n",
       "\u001b[35m╰────────────────────────────────────────────────────────────────────╯\u001b[0m\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">\n",
       "</pre>\n"
      ],
      "text/plain": [
       "\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "## Investment Lead Report\n",
      "\n",
      "```markdown\n",
      "# Final Investment Report: AAPL, MSFT, GOOGL\n",
      "\n",
      "## 1. Portfolio Strategy Development 💼\n",
      "\n",
      "### Allocation Strategy\n",
      "- **Microsoft Corporation (MSFT)**: Allocate 40%\n",
      "  - Justification: Strong market leadership in cloud and enterprise solutions represents sustainable growth. Manages risks effectively due to diversification and robust financial health.\n",
      "  \n",
      "- **Apple Inc. (AAPL)**: Allocate 35%\n",
      "  - Justification: Continued brand strength and expansion in global markets. Monitors regulatory risks but benefits from diversifying product offerings and consistent consumer base.\n",
      "\n",
      "- **Alphabet Inc. (GOOGL)**: Allocate 25%\n",
      "  - Justification: Innovation in AI and digital advertising ensures long-term potential. Regulatory risks are substantial but manageable with proactive strategy adjustments.\n",
      "\n",
      "### Risk-Reward Optimization\n",
      "- Favor companies with robust cash flows and diversified revenue streams.\n",
      "- Position for long-term growth while mitigating regulatory and market volatility risks.\n",
      "\n",
      "### Diversification and Timeframes\n",
      "- Ensure sectoral balance within tech industry, focusing on cloud services, consumer electronics, and digital advertising.\n",
      "- Set a medium to long-term investment horizon (~3-5 years) to accommodate growth realization and regulatory adaptation.\n",
      "\n",
      "## 2. Investment Rationale 📝\n",
      "\n",
      "### Allocation Decisions Explained\n",
      "- **Microsoft (MSFT)**: Prioritized for its stable yet expansive growth vector through cloud services and software solutions. The company stands resilient amid potential disruptions.\n",
      "- **Apple (AAPL)**: Offers enduring appeal and profitability. Risk factors are well mitigated by brand resilience and market adaptability.\n",
      "- **Alphabet (GOOGL)**: Selected for innovation leadership; despite high risks, has potential for significant gains through strategic technological advancements.\n",
      "\n",
      "### Analysis and Concerns\n",
      "- Macro-economic uncertainties affecting all tech investments.\n",
      "- Regulation and market competition are persistent but not prohibitive threats.\n",
      "\n",
      "### Growth Catalysts\n",
      "- Cloud computing expansions (MSFT)\n",
      "- New product launches and service integrations (AAPL)\n",
      "- Breakthroughs in AI and advertising technology (GOOGL)\n",
      "\n",
      "## 3. Recommendation Delivery 📊\n",
      "\n",
      "### Clear Allocations\n",
      "- MSFT: 40%\n",
      "- AAPL: 35%\n",
      "- GOOGL: 25%\n",
      "\n",
      "### Investment Thesis\n",
      "- Emphasize on tech sector's leading giants with firm footholds in transformative areas (cloud, consumer tech, AI).\n",
      "\n",
      "### Actionable Insights\n",
      "- Continual monitoring of regulatory landscapes and tech innovations.\n",
      "- Adjust allocations as market dynamics shift, maintaining diversification.\n",
      "\n",
      "### Risk Considerations\n",
      "- Address company-specific regulatory and competitive challenges.\n",
      "- Stress test scenarios to prepare for adverse global economic conditions.\n",
      "\n",
      "---\n",
      "\n",
      "### Conclusion\n",
      "This investment strategy captures Microsoft's reliable growth, Apple's robust market position, and Alphabet's high innovation potential. Balancing risk exposure with strategic allocations ensures a promising portfolio poised for technological advancements and market leadership.\n",
      "\n",
      "### Disclaimer\n",
      "This portfolio recommendation is for informational purposes only and should not be construed as direct investment advice. Individual financial situations should be considered independently, ideally with professional advisor consultation.\n",
      "```\n",
      "\n"
     ]
    }
   ],
   "source": [
    "task3 = Task(\n",
    "    description=dedent(f\"\"\"\\\n",
    "        You are PortfolioSage-X, a distinguished Senior Investment Lead at Goldman Sachs expert in:\n",
    "        - Portfolio strategy development\n",
    "        - Asset allocation optimization\n",
    "        - Risk management\n",
    "        - Investment rationale articulation\n",
    "        - Client recommendation delivery\n",
    "\n",
    "        Instructions:\n",
    "        1. Portfolio Strategy 💼\n",
    "           - Develop allocation strategy\n",
    "           - Optimize risk-reward balance\n",
    "           - Consider diversification\n",
    "           - Set investment timeframes\n",
    "        2. Investment Rationale 📝\n",
    "           - Explain allocation decisions\n",
    "           - Support with analysis\n",
    "           - Address potential concerns\n",
    "           - Highlight growth catalysts\n",
    "        3. Recommendation Delivery 📊\n",
    "           - Present clear allocations\n",
    "           - Explain investment thesis\n",
    "           - Provide actionable insights\n",
    "           - Include risk considerations\n",
    "\n",
    "        Based on the following investment analysis and ranking, develop a portfolio allocation strategy and provide a final investment report in markdown format:\n",
    "\n",
    "        {report2}\n",
    "    \"\"\"),\n",
    "    tools=[]\n",
    ")\n",
    "final_report = investment_lead.do(task3)\n",
    "print(\"\\n## Investment Lead Report\\n\")\n",
    "print(final_report)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "ab974f06",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "All reports have been saved to investment_full_report.md\n"
     ]
    }
   ],
   "source": [
    "# Combine all reports into one markdown string\n",
    "all_reports_md = (\n",
    "    \"# Stock Analyst Report\\n\\n\"\n",
    "    f\"{report1}\\n\\n\"\n",
    "    \"# Research Analyst Report\\n\\n\"\n",
    "    f\"{report2}\\n\\n\"\n",
    "    \"# Investment Lead Report\\n\\n\"\n",
    "    f\"{final_report}\\n\"\n",
    ")\n",
    "\n",
    "# Write to a markdown file\n",
    "with open(\"investment_full_report.md\", \"w\") as f:\n",
    "    f.write(all_reports_md)\n",
    "\n",
    "print(\"All reports have been saved to investment_full_report.md\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
